#ifndef _EVENTLOOPTHREADPOOL_
#define _EVENTLOOPTHREADPOOL_

#include "noncopyable.h"
#include "EventLoopThread.h"

#include <string>
#include <vector>
#include <memory>
#include <functional>

class EventLoop;

class EventLoopThreadPool : noncopyable{
public:
    using ThreadInitCallback  = std::function<void(EventLoop*)>;
    EventLoopThreadPool(EventLoop *baseloop, const std::string name);
    ~EventLoopThreadPool();
    inline void setThreadNum(int nums){ threadNums_ = nums; }
    void start(const ThreadInitCallback& cb = ThreadInitCallback());
    EventLoop* getNextLoop();
    std::vector<EventLoop*> getAllLoops();
    inline bool started() const {   return started_; }
    inline std::string name() const { return name_; }
    
private:
    EventLoop *baseLoop_;
    std::string name_;
    bool started_;
    int threadNums_;
    int next_;
    std::vector<std::unique_ptr<EventLoopThread>> threads_;
    std::vector<EventLoop*> loops_;
};

#endif